package main

import "fmt"

func main() {
	s1 := []int{10, 30, 50, 70, 90}
	fmt.Printf("s1 %p, %p, l=%-2d, c=%-2d, %v \n", &s1, &s1[0], len(s1), cap(s1), s1)

	s2 := s1
	fmt.Printf("s2 %p, %p, l=%-2d, c=%-2d, %v \n", &s2, &s2[0], len(s2), cap(s2), s2)

	s3 := s1[:] // 共用
	fmt.Printf("s3 %p, %p, l=%-2d, c=%-2d, %v \n", &s3, &s3[0], len(s3), cap(s3), s3)
	fmt.Println("~~~~~~~~~~~~~~~~~~~~~~~~~~~")

	s4 := s1[1:] // 掐头
	fmt.Printf("s4 %p, %p, l=%-2d, c=%-2d, %v \n", &s4, &s4[0], len(s4), cap(s4), s4)

	s5 := s1[1:4]
	fmt.Printf("s5 %p, %p, l=%-2d, c=%-2d, %v \n", &s5, &s5[0], len(s5), cap(s5), s5)

	s5 = append(s5, 111)
	fmt.Printf("s1 %p, %p, l=%-2d, c=%-2d, %v \n", &s1, &s1[0], len(s1), cap(s1), s1)
	fmt.Printf("s5 %p, %p, l=%-2d, c=%-2d, %v \n", &s5, &s5[0], len(s5), cap(s5), s5)

	s6 := s1[:4]
	fmt.Printf("s6 %p, %p, l=%-2d, c=%-2d, %v \n", &s6, &s6[0], len(s6), cap(s6), s6)

	s7 := s1[1:1]
	fmt.Printf("s7 %p, l=%-2d, c=%-2d, %v \n", &s7, len(s7), cap(s7), s7)

	s7 = append(s7, -1)
	fmt.Printf("s7 %p, %p, l=%-2d, c=%-2d, %v \n", &s7, &s7[0], len(s7), cap(s7), s7)
	fmt.Printf("s1 %p, %p, l=%-2d, c=%-2d, %v \n", &s1, &s1[0], len(s1), cap(s1), s1)

	s8 := s1[4:4]
	fmt.Printf("s8 %p, l=%-2d, c=%-2d, %v \n", &s8, len(s8), cap(s8), s8)

	s9 := s1[5:5] // len=0, cap=0
	s9 = append(s9, 100)
	fmt.Printf("s9 %p, %p, l=%-2d, c=%-2d, %v \n", &s9, &s9[0], len(s9), cap(s9), s9)

}
